<?php
class main extends spController
{
	function index(){ // 这里是首页
		$tpl	 = $this->spArgs("tpl", "green"); // 这里接收tpl参数，使得模板变化
		$guestbook = spClass("guestbook"); 
		$this->results = $guestbook->findAll(); 
		$this->display("{$tpl}/index.html");
	}
	function write(){ // 这里是留言
		$guestbook = spClass("guestbook");
		$newrow = array( // 这里制作新增记录的值
			'name' => $this->spArgs('name'), 
			'title' => $this->spArgs('title'), // 从spArgs获取到表单提交上来的title
			'contents' => $this->spArgs('contents'),
		);
		$guestbook->create($newrow); 
		echo "留言成功，<a href=/index.php>返回</a>";
	}
}	